
// ConsumeInfo.java

package com.ruoyi.hospital.entity.check;

import com.ruoyi.hospital.entity.PackageChargeItem;
import com.ruoyi.hospital.entity.PackageChargeVO;

import java.util.ArrayList;
import java.util.List;

/**
 * 耗材明细
 */
@lombok.Data
public class CheckConsumeInfo {
    /**
     * 耗材包总额
     */
    private Long consumeCharge = 0L;
    /**
     * 患者的原耗材
     */
    private List<CheckConsumeInfoFromPat> fromPat;
    /**
     * 护士补充的耗材
     */
    private List<CheckConsumeInfoFromNur> fromNur;

    public void init(PackageChargeVO packageCharge) {
        if (this.getFromPat() == null) this.setFromPat(new ArrayList<CheckConsumeInfoFromPat>());
        if (this.getFromNur() == null) this.setFromNur(new ArrayList<CheckConsumeInfoFromNur>());
        for (PackageChargeItem item : packageCharge.getSuppliesChargeItemList()) {
            if (item.getNewFlag() == 0) {
                CheckConsumeInfoFromPat patNode = new CheckConsumeInfoFromPat();
                patNode.setPkgId(item.getPackageId());
                patNode.setPkgName(item.getPackageName());
                patNode.setPrice(item.getPrice());
                patNode.setNum(item.getCount());
                patNode.setCost(item.getPrice() * item.getCount());
                this.setConsumeCharge(this.getConsumeCharge() + item.getPrice() * item.getCount());
                this.fromPat.add(patNode);
            }
            if (item.getNewFlag() == 1) {
                CheckConsumeInfoFromNur nurNode = new CheckConsumeInfoFromNur();
                nurNode.setPkgId(item.getPackageId());
                nurNode.setPkgName(item.getPackageName());
                nurNode.setPrice(item.getPrice());
                nurNode.setNum(item.getCount());
                nurNode.setCost(item.getPrice() * item.getCount());
                this.setConsumeCharge(this.getConsumeCharge() + item.getPrice() * item.getCount());
                this.fromNur.add(nurNode);
            }
        }


    }
}
